package com.xinfu.newproject.presenter;

import com.xinfu.newproject.bean.certifition.UntyingBean;
import com.xinfu.newproject.bean.certifition.UntyingBody;
import com.xinfu.newproject.callback.MyCallBack;
import com.xinfu.newproject.model.certifition.UntyingModel;
import com.xinfu.newproject.view.IView;

import io.reactivex.disposables.Disposable;

public class UntyingPresenter {
    private IView.IUntyingView mIUntyingView;

    private UntyingModel mUntyingModel;

    public UntyingPresenter(IView.IUntyingView iUntyingView) {
        this.mIUntyingView = iUntyingView;
        mUntyingModel = new UntyingModel();
    }

    /**
     * 登录
     */
    public void untying() {
        mIUntyingView.showProgress();
        UntyingBody untyingBody = new UntyingBody(mIUntyingView.header(), mIUntyingView.id());

        mUntyingModel.untying(untyingBody, new MyCallBack<UntyingBean>() {
            @Override
            public void onSuccess(UntyingBean untyingBean) {
                mIUntyingView.hideProgress();
                if (untyingBean.isSuccess()) {
                    mIUntyingView.getData(untyingBean);
                } else {
                    mIUntyingView.showToast(untyingBean.getMessage());
                }
            }

            @Override
            public void onError(String header, String message) {
                mIUntyingView.hideProgress();
                mIUntyingView.showToast(message);
            }

            @Override
            public void onDispose(Disposable disposable) {
                mIUntyingView.closeDispose(disposable);
            }
        });


    }


//    private Map<String, String> createParaMap() {
//        Map<String, String> paraMap = new HashMap<>();
//        paraMap.put("userName", mIRegisterView.getUserName());
//        return paraMap;
//    }

}
